<?php

function smarty_function_percentage($params, &$smarty)
{
/*
    if (empty($params['total'])) {
        $smarty->trigger_error("percentage: missing 'total' parameter");
        return;
    } elseif (empty($params['value'])) {
        $smarty->trigger_error("percentage: missing 'value' parameter");
        return;
    }
  */  
    $total = $params['total'];
    $value = $params['value'];

	if ($total>0) {
		return round(($value * 100) / $total);	
	}
	return 0;
}

?>
